package 力扣日常刷题.木22二月.第04天210;

/**
 * @author 帅小伙
 * @date 2022/2/10
 * @description
 */
public class Demo34反转单词顺序 {

    public String reverseWords(String s) {
        String[] strings = s.split(" ");
        StringBuffer sb = new StringBuffer();
        for (int i = strings.length-1; i >= 0 ; i--) {
            if("".equals(strings[i].trim()))continue;
            sb.append(strings[i]).append(" ");
        }
        return sb.toString().trim();
    }

}
